package com.blkj.iam.core.security.util;

import cn.hutool.captcha.generator.CodeGenerator;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import org.springframework.stereotype.Component;

/**
 * @description: 正数验证码工具类
 * @author: Ethan
 * @create: 2025-04-23
 **/
@Component
public class PositiveNumberGenerator implements CodeGenerator {
    private final int length = 4;

    @Override
    public String generate() {
        // 生成随机正数验证码
        return RandomUtil.randomNumbers(length);
    }

    @Override
    public boolean verify(String code, String userInputCode) {
        return StrUtil.equals(code, userInputCode);
    }
}
